<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../js/vue.js"></script>
</head>
<style>
    * {
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .nav {
        display: flex;
        justify-content: center;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 40px;
    }

    .item {
        flex: 1;
        line-height: 40px;
        background-color: #000;
        margin-right: 1px;
        color: tomato;
        text-align: center;
        cursor: pointer;
    }

    .active {
        background-color: tomato;
        color: #fff;
    }
    .content {
        text-align: center;
    }
</style>

<body>
    <div id="app">
        <div class="nav">
            <div class="item" v-for="item in list" :key="item.id" :class="{active:activeindex==item.id}"
                @click="change(item)">
                {{item.msg}}
            </div>
        </div>
        <component :is="com"></component>
    </div>
</body>
<template id="home">
    <div class="content">
        首页
    </div>
</template>
<template id="about">
    <div class="content">
        关于
    </div>
</template>
<template id="list">
    <div class="content">
        列表
    </div>
</template>
<template id="mine">
    <div class="content">
        我的
    </div>
</template>

<script>
    let home = {
        template: "#home",
    }
    let about = {
        template: "#about",
    }
    let list = {
        template: "#list",
    }
    let mine = {
        template: "#mine",
    }
    new Vue({
        el: "#app",
        data: {
            com: "home",
            activeindex: 1,
            list: [
                {id: 1, msg: "首页", com: "home"},
                {id: 2, msg: "关于", com: "about"},
                {id: 3, msg: "列表", com: "list"},
                {id: 4, msg: "我的", com: "mine"},
            ]
        },
        components: {
            home,
            about,
            list,
            mine
        },
        methods: {
            change(item) {
                this.com = item.com;
                this.activeindex = item.id;
            }
        }

    })
</script>

</html>